package com.leff.cards.web.requests;

import android.util.Log;

import com.leff.cards.util.Secrets;
import com.leff.cards.util.Dictionary;
import com.leff.cards.util.Settings;
import com.leff.cards.web.WebRequest;

public class GcmUnregisterRequest extends WebRequest implements Secrets {

	private boolean mFromLogout;
	
	public GcmUnregisterRequest(long id, String token) {
		this(id, token, false);
	}
	public GcmUnregisterRequest(long id, String token, boolean fromLogout) {
		super(WebCommand.UNREGISTER_DEVICE);
		
		mParameters.put(Parameter.ID, id);
		mParameters.put(Parameter.GCM_ID, token);
		
		mFromLogout = fromLogout;
	}

	@Override
	protected void parseResultDictionary(Dictionary dict) {
		Log.v(TAG, "Successfully unregistered device token");

		if(mFromLogout) {
			Settings.clearNotificationsEnabled();
		} else {
			Settings.setNotificationsEnabled(false);
		}
	}
}
